/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sg.edu.nus.iss.ooad.jass.ui;

import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Label;
import java.awt.Panel;  
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import sg.edu.nus.iss.ooad.jass.entity.Jobseeker; 
import sg.edu.nus.iss.ooad.jass.ui.widget.AbstractJASSRegularWindow;
import sg.edu.nus.iss.ooad.jass.ui.widget.JASSRegularPanel;

/**
 *
 * @author Administrator
 */
public class JASSJobSeekerProfileForm  extends AbstractJASSRegularWindow {

          private static final long serialVersionUID = -8249586943029528796L;
        //form components
       

        private Label labelName = null;
        private Label labelAddress = null; 
        private Label labelEmail = null;
        private Label labelResume = null;
        private Label textName = null;
        private Label textAddress = null;  
        private Label textEmail = null;
        private Label textResume = null;
        private JASSRegularPanel formPanel = null;
        private Panel inputPanel = null;
        private Panel buttonPanel = null;
        private Button btnCancel = null; 
        private GridBagLayout inputLayout = null; 

        /**
         * Default Constructor JASSJobseekerRegistrationForm
         */
        public JASSJobSeekerProfileForm(Jobseeker jobseeker) {
                super("Job Advertisement and Search System", new Dimension(550, 400));
                initComponents(jobseeker);
        }

        @Override
        public void attachComponent(Component c, int gridx, int gridy, int gridwidth, int gridheight, int fill) {
                GridBagConstraints constraint = new GridBagConstraints();
                constraint.gridx = gridx;
                constraint.gridy = gridy;
                constraint.gridwidth = gridwidth;
                constraint.gridheight = gridheight;
                constraint.fill = fill;
                constraint.insets = new Insets(4, 4, 4, 4);
                constraint.weightx = 1.0;
                constraint.weighty = 1.0;
                inputPanel.add(c);
                inputLayout.setConstraints(c, constraint);
        }

        /**
         * This methods will initialize all form components.
         */
        public void initComponents(Jobseeker jobseeker) {
                //initialize components s

                
                labelName = new Label("Name");
                labelAddress = new Label("Address"); 
                labelEmail = new Label("Email");
                labelResume = new Label("Resume");
                
                textName = new Label("");
                textAddress = new Label( "");
                textEmail = new Label( "");
                textResume = new Label("");

                formPanel = new JASSRegularPanel("Jobseeker Profile");
                formPanel.setPreferredSize(new Dimension(500,300));
                inputPanel = new Panel();
                buttonPanel = new Panel();
             
                btnCancel = new Button("Cancel");

               
                btnCancel.addActionListener(new CancelActionListener());

                //setLayout
                buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
               
                buttonPanel.add(btnCancel);
                formPanel.add(buttonPanel, BorderLayout.SOUTH);

                inputLayout = new GridBagLayout();
                inputPanel.setLayout(inputLayout);
                
                attachComponent(labelName, 0, 1, 1, 1);
                attachComponent(textName, 1, 1, 1, 1);
                attachComponent(labelEmail, 0, 2, 1, 1);
                attachComponent(textEmail, 1, 2, 1, 1);
                attachComponent(labelAddress, 0, 3, 1, 1);
                attachComponent(textAddress, 1, 3, 1, 1);
                attachComponent(labelResume, 0, 4, 1, 1);
                attachComponent(textResume, 1, 4, 1, 1);
                formPanel.add(inputPanel, BorderLayout.CENTER);

                //add to the frame
                add(formPanel);
                pack();
        }

        /**
         * Display the job seeker profile
         * @param jobseeker
         */

        public void display(Jobseeker jobseeker) {
                textName.setText(jobseeker.getName());
                textAddress.setText(jobseeker.getAddress());
                textEmail.setText(jobseeker.getEmail());  
                textResume.setText(jobseeker.getResume()); 
        }

          /**
         * Cancel action handler. It is called when the user click button "Cancel".
         */
        class CancelActionListener implements ActionListener {

                public void actionPerformed(ActionEvent e) {
                       close();
                }
        }


        @Override
        public void resetForm() {
                throw new UnsupportedOperationException("Not supported yet.");
        }


}
